<extend name="desktop_default/template/user/base_user" />
<block name="area_header">
    <link rel="stylesheet" href="__CSS__/user/order/style.css">
</block>

<block name="area_top">

</block>
<block name="user_top">

</block>
<block name="main_content">
    <div class="order">
        <div class="user-tab">
            <a <eq name="status" value="0">class="selected" </eq>href="{:U('mengwu/user/order',array('status'=>0,'p'=>$p))}">全部订单</a>
            <a <eq name="status" value="1">class="selected" </eq>href="{:U('mengwu/user/order',array('status'=>1,'p'=>$p))}">待付款（{$status_count[1]}）</a>
            <a <eq name="status" value="3">class="selected" </eq>href="{:U('mengwu/user/order',array('status'=>3,'p'=>$p))}">待收货（{$status_count[3]}）</a>
            <a <eq name="status" value="6">class="selected" </eq>href="{:U('mengwu/user/order',array('status'=>6,'p'=>$p))}">待评价({$status_count[6]})</a>
        </div>
        <div class="order-detail">
            <div class="head">
                <div class="ch sp">商品</div>
                <div class="ch count">数量</div>
                <div class="ch price">实付金额</div>
                <div class="ch state">交易状态</div>
                <div class="ch oper">操作</div>
            </div>
            <empty name="order_list">
                <div class="list">
                    <div class="empty-list">无订单</div>
                </div>
            </empty>
            <volist name="order_list" id="vo">
                <div class="list">
                    <div class="tooltip">
                        订单号：<span class="order-code">{$vo.order_code}</span>下单时间：{$vo.createtime|date="Y-m-d H:i:s",###}
                    </div>
                    <volist name="vo.items" id="item" key="k">
                        <eq name="k" value="1">
                            <div class="cl sp">
                                <div class="sp-img">
                                    <a href="{:U('mengwu/spdetail/index',array('id'=>$item['p_id']))}" target="_blank"><img src="{:C('PICTURE_REMOTE_URL')}{$item.img}"></a>
                                </div>
                                <div class="introduce">
                                    <div class="caption">
                                        <a href="{:U('mengwu/spdetail/index',array('id'=>$item['p_id']))}" target="_blank">{$item.name}</a>
                                    </div>
                                    <div class="sorted">
                                        <span>{$item.sku_desc}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="cl count">{$item.count}件</div>
                            <div class="cl <gt name='vo.items_count' value='1'>merge</gt> price"><em class="rmb">￥</em>{:number_format($vo['price']-$vo['discount_money'],2,'.','')}</div>
                            <div class="cl <gt name='vo.items_count' value='1'>merge</gt> state">{$vo.status_desc}<br><a href="{:U('mengwu/user/order_detail',array('order_code'=>$vo['order_code']))}">订单详情</a></div>
                            <div class="cl <gt name='vo.items_count' value='1'>merge</gt> oper">
                                <in name="vo.status_desc" value="交易关闭,订单退回">
                                    <else />
                                    <eq name="vo.status_ss" value="1">
                                        <a class="btn pay" href="{:U('mengwu/order/pay',array('id'=>$vo['id']))}" target="_blank">去支付</a>
                                        <a class="btn qx" href="javascript:void(0);" data-code="{$vo.order_code}">取消订单</a>
                                    </eq>
                                    <eq name="vo.status_ss" value="2">
                                        <a class="btn confirm" href="{:U('mengwu/user/order_detail',array('order_code'=>$vo['order_code']))}">确认收货</a>
                                        <a class="btn tuihuo" href="{:U('mengwu/user/return_refund',array('order_code'=>$vo['order_code']))}">退货退款</a>
                                    </eq>
                                    <eq name="vo.status_ss" value="3">
                                        <a class="btn confirm" href="{:U('mengwu/user/order_detail',array('order_code'=>$vo['order_code']))}">确认收货</a>
                                        <a class="btn tuihuo" href="{:U('mengwu/user/return_refund',array('order_code'=>$vo['order_code']))}">退货退款</a>
                                    </eq>
                                    <eq name="vo.status_ss" value="6">
                                        <a class="btn pingjia" href="{:U('mengwu/user/order_pingjia',array('order_code'=>$vo['order_code']))}">去评价</a>
                                        <a class="btn cs" href="{:U('mengwu/user/service',array('order_code'=>$vo['order_code']))}">申请售后</a>
                                    </eq>
                                    <eq name="vo.status_ss" value="7">
                                        <a class="btn cs" href="{:U('mengwu/user/service',array('order_code'=>$vo['order_code']))}">申请售后</a>
                                    </eq>
                                </in>
                            </div>
                        </eq>
                        <gt name="k" value="1">
                            <div class="cl sp">
                                <div class="sp-img">
                                    <a href="{:U('mengwu/spdetail/index',array('id'=>$item['p_id']))}" target="_blank"><img src="{:C('PICTURE_REMOTE_URL')}{$item.img}"></a>
                                </div>
                                <div class="introduce">
                                    <div class="caption">
                                        <a href="{:U('mengwu/spdetail/index',array('id'=>$item['p_id']))}" target="_blank">{$item.name}</a>
                                    </div>
                                    <div class="sorted">
                                        <span>{$item.sku_desc}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="cl count">{$item.count}件</div>
                            <div class="cl price"></div>
                            <div class="cl state"></div>
                            <div class="cl oper"></div>
                        </gt>
                    </volist>
                </div>
            </volist>
        </div>
        <notempty name="order_list">
            {$show}
        </notempty>
    </div>

</block>
<block name="area_footer">
<script type="text/javascript">
    var confirm = antd.Modal.confirm;
    var message = antd.message;
    $('.btn.qx').click(function(){
        var code = $(this).attr('data-code');
        confirm({
            title: '您是否确认要取消这个订单',
            content: '',
            onOk:function() {
                var hide = message.loading('正在执行中...',0);
                var url = document.getElementsByTagName('base')[0].href + '/mengwu/mengwuApi/order_cancel';
                let data = {
                    order_code: code
                };
                _post(url,jQuery.param(data), {
                    //处理返回数据
                    data_back: function(data){
                        hide();
                        setTimeout(function(){
                            if(data.status){
                                message.success('操作成功！');
                                setTimeout(function(){window.location.reload()},500);
                            }else{
                                message.error('操作失败！');
                            }
                        },500);

                    }
                });
            },
            onCancel:function() {}
        });
    });
</script>
</block>
